﻿using System;
using BikeBouncer.BusinessLayer;
using Devv.Core.Utils;

namespace BikeBouncer.Site
{
	public partial class Contact_aspx : BasePage
	{
		#region Main methods

		protected void Page_Load(Object sender, EventArgs e)
		{
			ValTxtEmail.ValidationExpression = RegexUtil.Email;
			PanSent.Visible = false;

			if (!Page.IsPostBack)
			{
				Form.DefaultButton = ButSend.UniqueID;
				TxtSubject.Text = Request.QueryString["subject"];
			}
		}

		#endregion

		#region Send email

		protected void ButSend_Click(Object sender, EventArgs e)
		{
			Page.Validate();

			if (Page.IsValid)
			{
				MailManager.Contact(TxtName.Text, TxtEmail.Text, TxtSubject.Text, TxtMessage.Text);

				PanForm.Visible = false;
				PanSent.Visible = true;
			}
		}

		#endregion
	}
}